package com.gulimall.common.utils;

import lombok.Data;

import java.util.List;

/**
 * @author Administrator
 * @date 2021/11/23 6:40
 */
@Data
public class ServiceResponse<T> {
    private int code;
    private String message;
    private T data;
    private List<T> list;
    private PageList<T> pageList;

    public ServiceResponse() {
        this(ResponseCode.SUCCESS);
    }

    public ServiceResponse(ResponseCode responseCode) {
        this(responseCode.getCode(), responseCode.getMessage());
    }

    public ServiceResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceResponse<T> setPageList(PageList<T> pageList) {
        this.pageList = pageList;
        return this;
    }

    public ServiceResponse<T> setList(List<T> list) {
        this.list = list;
        return this;
    }

    public ServiceResponse<T> setData(T data) {
        this.data = data;
        return this;
    }
}
